export enum QueryOptEnum {
  EQ = 'eq',
  NE = 'ne',
  GT = 'gt',
  GE = 'ge',
  LT = 'lt',
  LE = 'le',
  DATE_BWT = 'date_bwt',
  NUM_BWT = 'num_bwt',
  IN = 'in',
  LIKE = 'like',
  LEFT_LIKE = 'left_like',
  RIGHT_LIKE = 'right_like',
  EQ_WITH_ADD = 'eq_with_add',
  SQL_RULES = 'ext',
}

const options: OptionsItem[] = [
  {
    label: '等于',
    value: QueryOptEnum.EQ,
  },
  {
    label: '不等于',
    value: QueryOptEnum.NE,
  },
  {
    label: '大于',
    value: QueryOptEnum.GT,
  },
  {
    label: '大于等于',
    value: QueryOptEnum.GE,
  },
  {
    label: '小于',
    value: QueryOptEnum.LT,
  },
  {
    label: '小于等于',
    value: QueryOptEnum.LE,
  },
  {
    label: '日期区间',
    value: QueryOptEnum.DATE_BWT,
  },
  {
    label: '数字区间',
    value: QueryOptEnum.NUM_BWT,
  },
  {
    label: '包含',
    value: QueryOptEnum.IN,
  },
  {
    label: '全模糊',
    value: QueryOptEnum.LIKE,
  },
  {
    label: '左模糊',
    value: QueryOptEnum.LEFT_LIKE,
  },
  {
    label: '右模糊',
    value: QueryOptEnum.LEFT_LIKE,
  },
];
type OptionsItem = { label: string; value: string; disabled?: boolean };

export const getQueryOptions = (opts: string[]) => {
  const selectOptions: OptionsItem[] = [];
  opts.forEach((opt) => {
    const comOpt = options.find((o) => o.value === opt) as OptionsItem;
    if (comOpt) selectOptions.push(comOpt);
  });
  return selectOptions;
};
